package com.itheima.Controller;

import com.itheima.Service.OrderService;
import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.OrderDTO;
import com.itheima.pojo.OrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**
     * 根据id查询预约信息
     */

    @PostMapping("/findById")
    public Result<OrderVO> orderlist(Integer id){
        log.info("查询预约信息:{}",id);
        OrderVO orderVO=orderService.listr(id);
        return new Result<>(true, MessageConstant.QUERY_ORDER_SUCCESS,orderVO);
    }
    /**
     * 体检预约
     */
    @PostMapping("/submitOrder")
    public  Result order(@RequestBody OrderDTO orderDTO){
        log.info("提交预约信息");
        Integer data = orderService.order(orderDTO);
        return new Result(true,MessageConstant.ORDER_SUCCESS,data);
    }
}
